//
//  Virtual_destructors.hpp
//  learnC++
//
//  Created by liuzhibing on 2018/6/15.
//  Copyright © 2018年 yunfan.com. All rights reserved.
//

#ifndef Virtual_destructors_hpp
#define Virtual_destructors_hpp

#include <stdio.h>
#include <iostream>

class Base9 {
public:
    int m_value;
public:
    virtual ~Base9(){
        std::cout << "This is ~Base()\n";
    }

};

class Derived9 : public Base9 {
    int *m_arr;
    
public:
    Derived9(int length){
        m_value = length;
        m_arr = new int[length]();
    }
    
    virtual ~Derived9(){
        delete [] m_arr;
        std::cout << "This is ~Derived()\n";
    }
    
};


/*
 
 Derived9 *d = new Derived9(3);
 Base9 *base = d;
 delete base;
 
 */

#endif /* Virtual_destructors_hpp */
